import request from '@/utils/request'
const base = 'http://localhost:8002'
// 获取文章列表
export function fetchList(id, page, limit) {
  return request({
    baseURL: base,
    url: `/article/userBlog/${id}/${page}/${limit}`,
    method: 'get'
  })
}
// 获取公开文章,下拉加载
export function fetchAllArticle(count) {
  return request({
    baseURL: base,
    url: `/article/all/${count}`,
    method: 'get'
  })
}
// 根据id获取某用户公开文章,下拉加载
export function fetchAllArticleById(id, count) {
  return request({
    baseURL: base,
    url: `/article/all/${id}/${count}`,
    method: 'get'
  })
}
// 根据id获取文章
export function fetchArticle(id) {
  return request({
    baseURL: base,
    url: `/article/detail/${id}`,
    method: 'get'
  })
}
export function fetchArticleByTag(id, count) {
  return request({
    baseURL: base,
    url: `/article/tag/${id}/${count}`,
    method: 'get'
  })
}
export function fetchAnyArticle(id) {
  return request({
    baseURL: base,
    url: `/article/anyDetail/${id}`,
    method: 'get'
  })
}
// 获取标签库里面的标签
export function fetchTags() {
  return request({
    baseURL: base,
    url: '/article/tag',
    method: 'get'
  })
}
// 更新view
export function updateViews(userId, articleId) {
  return request({
    baseURL: base,
    url: `/article/view/${userId}/${articleId}`,
    method: 'put'
  })
}
// 查询文章
export function searchArticle(title) {
  return request({
    baseURL: base,
    url: `/article/searchArticles`,
    method: 'get',
    params: title
  })
}
// 创建文章
export function createArticle(data) {
  return request({
    baseURL: base,
    url: '/article/create',
    method: 'post',
    data
  })
}
// 删除文章
export function deleteArt(id) {
  return request({
    baseURL: base,
    url: `/article/deleteArticle/${id}`,
    method: 'delete'
  })
}
// 更新文章
export function updateArticle(id, data) {
  return request({
    baseURL: base,
    url: `/article/update/${id}`,
    method: 'put',
    data
  })
}
// 获取文章
export function fetchAllList(page, limit) {
  return request({
    baseURL: base,
    url: `/article/userBlog/${page}/${limit}`,
    method: 'get'
  })
}
// 通过标签获取文章
export function getArticleByTitle(title, page, limit) {
  return request({
    baseURL: base,
    url: `/article/getAllBlogByTitle/${title}/${page}/${limit}`,
    method: 'get'
  })
}
